//创建文字
function createWord(x,y,fontSize,textCorlor,text,isTrue=false,center="center"){
    let result = new egret.Sprite();
    var Text:egret.TextField = new egret.TextField(); 
    result.addChild(Text);
	Text.text = text;
    Text.textColor = textCorlor;
    Text.fontFamily = 'Microsoft YaHei';
    Text.size = fontSize;
    Text.bold = isTrue;
    Text.x = x;
    Text.y = y;
    Text.verticalAlign = "middle";
    Text.textAlign = center;
    return result;
}

//绘制圆形
function createCircle(sizeWid,lineCor,bgCorlor){
        let result = new egret.Sprite();
        var rankCir:egret.Shape = new egret.Shape();
        rankCir.x = 20;
        rankCir.y = 20;
        rankCir.graphics.lineStyle( sizeWid, lineCor );
        rankCir.graphics.beginFill( bgCorlor,20);
        rankCir.graphics.drawCircle( 0, 0, 40 );
        rankCir.graphics.endFill();
        result.addChild( rankCir );
        return result;
}

//排行榜信息
function createRank(x,y,rankNumber,cirLineCor,cirBgCor,img='touxiang_png',name="Amy",time="10.00"){
		let rankBox = new egret.Sprite();//容器
		rankBox.x = x;
		rankBox.y =y;
		var rankOne = createCircle(10,cirLineCor,cirBgCor);//圆背景
		rankOne.x = 10;
		rankOne.y = 10;
		rankBox.addChild(rankOne);
		var numOne = createWord(8,0,30,0x1a1a1a,rankNumber);//排名位置
		rankOne.addChild(numOne);
		var infoBg =   creatImg('title_bg_03_png');//白条
		infoBg.x = 50;
		infoBg.y = -15;
		infoBg.width = 388;
		rankBox.addChild(infoBg);
		var portrait1 =  creatImg(img);//头像
		portrait1.width = 70;
		portrait1.height = 70;
		portrait1.x = 60;
		portrait1.y = -6;
		rankBox.addChild(portrait1);
		var infoName = createWord(143,15,40,0xff4c22,name,true);//姓名
		rankBox.addChild(infoName);
        var infoTime = createWord(300,15,40,0xff4c22,time,true);//时间
		rankBox.addChild(infoTime);
		var timeOne = createWord(350,-10,26,0xff4c22,"time");//Time标识
		rankBox.addChild(timeOne);
        return rankBox;
}
declare var $;
function MYajax(requestData,url,successCallback){
				var tokenkey = "lkasdj213489ulkjadsf";
				var requestData = requestData;
				var url = url;
				requestData = JSON.stringify(requestData);
				var key = $.md5(requestData+tokenkey);
				
				$.ajax({
					type:"post",
					url:url,
					data:{'data':requestData,"key":key},
					async:true,
					success:function(res){
						successCallback(res);
					},
					dataType:'json',
					fail:function(e){
						console.log(e);
						console.log(key);
					}
					
				})
			}


